<style type="text/css">
    .modal .segment{margin-top: -1.2em;}
    .ui.modal .ui.form .field>.selection.dropdown { width: 250px;}
</style>
<div class="cont">
    <div class="position " id="page_title">
        <img alt="位置图标" src="dist/images/position.png"/>客户资源&gt;客户池
        <a ng-click="openDetail()" ng-hide="$needClientCache" title="打开新窗口查看"><i class="large External icon"></i>
        </a>
    </div> 
    <div class="mybackground">
        <div class="cont_fr_top">
            <div class="menus_top">
                <div class="menus_l">客户状态:</div>
                <ul id="nav">
                    <li ng-if="search_param.audit == -1" class="selected"  ><a  >全部</a></li>
                    <li ng-if="search_param.audit != -1" ><a   ng-click="search_param.audit=-1" >全部</a></li>
                    <li ng-repeat-start ="v in dataStatus" ng-if="search_param.audit == v.status"  class="selected" >
                       <a>{{v.statusTitle}}</a>
                    </li>
                    <li ng-repeat-end   ng-if="search_param.audit != v.status"   ng-click="search_param.audit=v.status" > 
                        <a>{{v.statusTitle}}</a>
                    </li>
                </ul>
                <div class="cont_fr_btn">
                    <div class="fr">
                        <a class="ui link"  href="javascript:;" ng-click="importTemplate()" target="_blank">下载导入模板</a>
                        <button class="cont_f_btn3" ng-click="import_paysUser()" >导入查账客户</button>
                        <button class="cont_f_btn1" ng-click="combineCustomer()">客户合并</button>
                    </div>
                </div>
            </div>
            <div class="menus">
                <div class="menus_con">
                    <div class="ui form">
                        <div class="four fields">
                            <div class="inline field">
                                <label>综合查询：</label>
                                <input type="text" ng-model="search_param.customer" ng-keyup="enterSearch($event)" placeholder="客户名/电话/编号"  style="width:160px">
                            </div>
                            <div class="inline field">
                                <label>服务人员</label>
                                <input type="text" ng-model="search_param.sales" ng-keyup="enterSearch($event)"  placeholder="服务人员" style="width:160px">
                            </div>
                            <div class="inline field">
                                <label for="textfield" class="li_lable">首次服务时间</label>
                                <div class="ui left icon input">
                                    <input datetimepicker  format='YYYY-MM-DD' id="start_time" ng-keyup="enterSearch($event)"
                                    placeholder="开始时间" ng-model="search_param.start_time" style="width:160px">
                                    <i class="calendar icon"></i>
                                </div>
                            </div>
                            <div class="inline field">
                                <div class="ui left icon input">
                                <input datetimepicker  format='YYYY-MM-DD' id="end_time" ng-keyup="enterSearch($event)"
                                placeholder="结束时间" ng-model="search_param.end_time" style="width:160px">
                                <i class="calendar icon"></i>
                            </div>
                            </div>
                        </div>
                        <div class="fields">
                            <div class="inline field">
                                <button class="clear_btn" style="margin-left: 5.7em;" ng-click="search()">查询</button>
                                <button class="clear_btn" ng-click="export_list()">导出</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="menus">
        <div class="menus_table">
            <table class="ui celled yellow striped table">
                <thead>
                    <tr>
                        <th style="min-width:70px;">客户编号</th>
                        <th style="min-width:120px;">客户名</th>
                        <th>电话</th>
                        <th>交款金额</th>
                        <th>服务人员</th>
                        <th>经理</th>
                        <th>所属分公司</th>
                        <th>首次服务时间</th>
                        <th>归属地</th>
                        <th>渠道</th>
                        <th>备注</th>
                        <th>状态</th>
                        <th class="center aligned">操作</th>
                    </tr>
                </thead>
                <tbody ng-hide="exist">
                    <tr ng-repeat="vlist in customer_list">
                        <td>{{::vlist.customer_code}}</td>
                        <td >
                                <div float_layer customer-id='vlist.customer_id' show-name="vlist.nickname"></div>
                        </td>
                        <td class="right aligned">{{::vlist.phone}}</td>
                        <td class="right aligned">{{::vlist.pay|currency:'':2}}</td>
                        <td>{{::vlist.sales_name}}</td>
                        <td>{{::vlist.manager_name}}</td>
                        <td>{{::vlist.sub_company}}</td>
                        <td class="right aligned">{{::vlist.create_time|limitTo:10:0}}</td>
                        <td class="ellipsis">{{::vlist.location}}</td>
                        <td class="ellipsis">
                            {{::vlist.source_name}}
                        </td>
                        <td class="ellipsis">{{::vlist.remark}}</td>
                        <td>
                            <span user-status status="{{::vlist.state}}"></span>
                        </td>
                        <td class="center aligned">
                            <div ng-click="openDetail('View360',vlist.customer_id)" ng-hide="$needClientCache">
                                <a>详情</a>    
                            </div>
                            
                            <!-- <a href="javascript:;" ng-click="editorShow(vlist.customer_id)">编辑</a> -->
                        </td>
                    </tr>
                </tbody>
                <tbody ng-show="!customer_list || customer_list.length == 0">
                    <tr>
                        <td colspan="13" style="text-align:center;margin-top:10px" class="null_data">没有找到数据~~~</td>
                    </tr>
                </tbody>
            </table>
            <div class="ui pagination menu" jspagination page-object="customerPage" page-func="getDataList" ng-show="customerPage.pageAll>1"></div>
        </div>
    </div>
</div>

<!-- 客户合并弹出层开始 -->
<div class="ui combine modal">
    <i class="close icon"></i>
    <div class="header_h4">客户合并</div>
    <div class="content">
        <form action="" class="combine form" name="frm-combine">
        <div class="ui form">
            <div class="two fields">
            <div class="field">
                <label class="label_fl">被合并客户</label>
                <select class="ui search dropdown"  placeholder="选择被合并客户"   ng-model="combine_data.from"></select>
            </div>
            <div class="field">
                <label class="label_fl">合并客户</label>
                <select class="ui search dropdown" placeholder="选择合并客户"  ng-model="combine_data.to"></select>
            </div>
          </div>
        </div>
        </form>
        <div class="ui error message" ng-show="combine_error">
            <div class="header">客户合并错误</div>
            <p>{{combine_error}}</p>
        </div>
    </div>
    <div class="actions"  >
        <button class="ui green button positive">{{'BTN_OK' | translate}}</button>
        <button class="ui grey button negative">{{'BTN_CANCEL' | translate}}</button>
    </div>
</div>
<!-- //客户合并弹出层结束 -->


<!-- 从查账与客户资料表导入客户信息 -->
<div class="ui import pay user modal">
    <i class="close icon"></i>
    <div class="header_h4">导入查账客户资料</div>
    <div class="content">
        <form action="#" class="import pays user" name="frm-add"  >
            <div class="ui three top attached steps">
                <div class="active step" ng-if="import_pays_step==1">
                    <i class="upload icon"></i>
                    <div class="content">
                        <div class="title">上传文件</div>
                        <div class="description">
                            选择你要上传的查账客户资料
                        </div>
                    </div>
                </div>
                <div class="completed step" ng-if="import_pays_step!=1">
                    <i class="upload icon"></i>
                    <div class="content">
                        <div class="title">上传文件</div>
                        <div class="description">
                            选择你要上传的查账客户资料
                        </div>
                    </div>
                </div>
                <div class="active step" ng-if="import_pays_step==2">
                    <i class="write icon"></i>
                    <div class="content">
                        <div class="title">编辑解析数据</div>
                        <div class="description">
                            编辑本批内重复数据
                        </div>
                    </div>
                </div>
                <div class="completed step" ng-if="import_pays_step==3">
                    <i class="write icon"></i>
                    <div class="content">
                        <div class="title">编辑解析数据</div>
                        <div class="description">
                            编辑本批内重复数据
                        </div>
                    </div>
                </div>
                <div class="disabled step" ng-if="import_pays_step==1">
                    <i class="write icon"></i>
                    <div class="content">
                        <div class="title">编辑解析数据</div>
                        <div class="description">
                            编辑本批内重复数据
                        </div>
                    </div>
                </div>
                <div class="active step" ng-if="import_pays_step==3">
                    <i class="info icon"></i>
                    <div class="content">
                        <div class="title">导入结果</div>
                        <div class="description">
                            导入结果显示
                        </div>
                    </div>
                </div>
                <div class="disabled step" ng-if="import_pays_step!=3">
                    <i class="info icon"></i>
                    <div class="content">
                        <div class="title">导入结果</div>
                        <div class="description">
                            导入结果显示
                        </div>
                    </div>
                </div>
            </div>
            <div class="ui segment" ng-show="import_pays_step==1">
                    <div class="ui error message" ng-show="import_pays_error.length>0&&import_pays_step==1">
                        <div class="header">上传错误</div>
                        <p>{{import_pays_error}}</p>
                    </div>
                    <div class="ui icon message" ng-show="is_uploading">
                        <i class="notched circle loading icon"></i>
                        <div class="content">
                            <div class="header">请耐心等待，文件正在上传中....</div>
                        </div>
                    </div>
                    <div class="ui center aligned basic segment">
                        <div class="ui row" ng-hide="is_uploading">
                            <div class="ui primary button"  ngf-select="import_file_change($file)"  name="import_file" ngf-pattern="'.xls,.xlsx'"
            ngf-accept="'.xls,.xlsx'" ngf-max-size="20MB">选择要上传的文件 </div>
                        </div>
                    </div>
            </div>
            <div class="row" ng-show="import_pays_step==2">
                <h5 class="ui red block small attched header" ng-click="show_fusion_data=!show_fusion_data" ng-init="show_fusion_data=1">
                    <i class="small red warning icon"></i>
                    <div class="content">
                        本批内重复记录,共有<b>{{import_data.fusion_count}}</b>条
                    </div>
                    <span class="ui notice">拖动可以合并数据</span>
                </h5>
                <div class="ui basic segment">
                    <table class="ui single table" ng-show="show_fusion_data">
                      <thead>
                        <tr>
                            <th>客户</th>
                            <th>电话</th>
                            <th>合同时间</th>
                            <th>产品</th>
                            <th>合同金额</th>
                            <th>付款信息</th>
                            <th>业务</th>
                            <th>经理</th>
                            <th>团队</th>
                        </tr>
                      </thead>
                      <tbody class="tb-move">
                        <tr pay-conbine ng-repeat="vUser in import_data.fusion" data-v="{{vUser.k}}" >
                            <td>{{vUser.customer_name}}</td>
                            <td>{{vUser.phone}}</td>
                            <td>{{vUser.contract_time|limitTo:10}}</td>
                            <td>{{vUser.product}}</td>
                            <td>{{vUser.contract_mount}}</td>
                            <td>
                                <div class="ui left aligned ordered list" >
                                    <div class="item">
                                        {{vUser.pay.pay_name}}&nbsp;{{vUser.pay.pay_time|limitTo:10}}&nbsp;{{vUser.pay.pay_way}}&nbsp;<b>{{vUser.pay.mount}}</b>&nbsp;{{vUser.pay.sales_person}}
                                    </div>
                                    <div class="item" ng-repeat="vpay in vUser.sub_user track by $index">
                                        {{vpay.pay.pay_name}}&nbsp;{{vpay.pay.pay_time|limitTo:10}}&nbsp;{{vpay.pay.pay_way}}&nbsp;<b>{{vpay.pay.mount}}</b>&nbsp;{{vpay.pay.sales_person}} &nbsp;&nbsp;<a class="ui link" ng-click="drag_remove(vUser.k, vpay.k)">取消合并</a>
                                    </div>
                                </div>
                            </td>
                          <td>{{vUser.sales_person}}</td>
                          <td>{{vUser.sales_manager}}</td>
                          <td>{{vUser.sales_sub_company}}</td>
                        </tr>
                      </tbody>
                    </table>
                </div>
                <h2 class="ui green block small attched header" ng-click="show_down_data=!show_down_data" ng-init="show_down_data=0" >
                    <i class="small checkmark icon"></i>
                    <div class="content">
                        本批内正常数据,共有<b>{{import_data.down.length}}</b>条
                    </div>
                </h2>
                <div class="ui basic segment" ng-if="import_data.down.length>0||import_data.fusion_count">
                    <table class="ui single table" ng-show="import_data.down&&show_down_data">
                      <thead>
                        <tr>
                            <th>客户</th>
                            <th>电话</th>
                            <th>合同时间</th>
                            <th>产品</th>
                            <th>合同金额</th>
                            <th>付款信息</th>
                            <th>业务</th>
                            <th>经理</th>
                            <th>团队</th>
                        </tr>
                      </thead>
                      <tbody >
                        <tr ng-repeat="vcustomer in import_data.down">
                            <td>{{vcustomer.customer_name}}</td>
                            <td>{{vcustomer.phone}}</td>
                            <td>{{vcustomer.contract_time|limitTo:10}}</td>
                            <td>{{vcustomer.product}}</td>
                            <td>{{vcustomer.contract_mount}}</td>
                            <td>
                                <div class="list" >
                                    <div class="item" ng-click="add()"  >
                                        {{vcustomer.pay.pay_name}}&nbsp;{{vcustomer.pay.pay_time|limitTo:10}}&nbsp;{{vcustomer.pay.pay_way}}&nbsp;<b>{{vcustomer.pay.mount}}</b>&nbsp;{{vcustomer.pay.sales_person}}
                                    </div>
                                </div>
                            </td>
                          <td>{{vcustomer.sales_person}}</td>
                          <td>{{vcustomer.sales_manager}}</td>
                          <td>{{vcustomer.sales_sub_company}}</td>
                        </tr>
                      </tbody>
                    </table>
                    <div class="content">
                        <div class="ui center aligned basic segment">
                            <span class="ui primary button" ng-click="import_data_save()">保存结果</span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row" ng-show="import_pays_step==3">
                <div class="ui green block small attched header" >
                    <i class="small checkmark icon"></i>
                    <div class="content">
                        本批成功处理查账流水<b>{{import_ok}}</b>条
                    </div>
                </div>

                <h5 class="ui red block small attched header" ng-click="show_error_data=!show_error_data" ng-init="show_error_data=1"  >
                    <i class="small red warning icon"></i>
                    <div class="content">
                        错误解析查账流水,共有<b>{{import_data.length}}</b>条
                    </div>
                </h5>
                <table class="ui single table" ng-show="show_fusion_data" ng-if="import_data.length>0">
                  <thead>
                    <tr>
                        <th>付款流水编号</th>
                        <th>客户</th>
                        <th>电话</th>
                        <th>合同时间</th>
                        <th>产品</th>
                        <th>合同金额</th>
                        <th>业务</th>
                        <th>经理</th>
                        <th>团队</th>
                        <th>错误信息</th>
                    </tr>
                  </thead>
                  <tbody class="tb-move">
                    <tr  ng-repeat="vUser in import_data" >
                        <td>{{vUser.pay_order}}</td>
                        <td>{{vUser.customer_name}}</td>
                        <td>{{vUser.phone}}</td>
                        <td>{{vUser.contract_time|limitTo:10}}</td>
                        <td>{{vUser.product}}</td>
                        <td>{{vUser.contract_mount}}</td>
                        <td>{{vUser.sales_person}}</td>
                        <td>{{vUser.sales_manager}}</td>
                        <td>{{vUser.sales_sub_company}}</td>
                        <td style="color:red;">{{vUser.error}}</td>
                    </tr>
                  </tbody>
                </table>
                <div class="ui icon message" ng-show="is_uploading&&import_pays_step==3">
                    <i class="notched circle loading icon"></i>
                    <div class="content">
                        <div class="header">
                            导入解析数据
                        </div>
                        <p>数据导入中，请耐心等待.....</p>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
$('.ui.dropdown').dropdown({on: 'hover' });
    $(function(){
            //
    });
</script>
